<?php
header('Content-Type: text/html; charset=UTF-8');

session_start();

@$userID =  $_SESSION['userId'];

if(empty($userID)){
	die(json_encode(array('status'=>false,'info'=>'操作超时！')));
}

@$outCash = $_REQUEST['outCash'];

require 'lib/db.php';

@$user = dbSelect('select money from user where id=:id',array('id'=>$userID));

if($outCash>$user['money']){
	die(json_encode(array('status'=>false,'info'=>'您的账户余额已不足！取款失败！')));
}

$flag = dbUpdate('update user set money=money-:outCash where id=:id',array('outCash'=>$outCash,'id'=>$userID));

if(!$flag){
	die(json_encode(array('status'=>false,'info'=>'取款失败！')));
}
echo json_encode(array('status'=>true,'money'=>$user['money']-$outCash));